USE [loan]
GO
/****** Object:  UserDefinedFunction [dbo].[DateFromParts]    Script Date: 04/25/2013 15:55:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*This function converts the three paramaters (year, month, day) supplied to a date
and thows an execption if they do not compute to a coect date, for eg 2013 2 29 is invalid*/
ALTER FUNCTION [dbo].[DateFromParts]
(
	@year INTEGER,
	@month INTEGER,
	@day INTEGER
)
RETURNS DATE
AS

BEGIN 
	Return Convert(Date, Convert(VARCHAR(4), @year) + '-' + Convert(VARCHAR(2), @month) + '-' + Convert(VARCHAR(2), @day))
END

